import 'package:collection/collection.dart';

void testFirstWhere() {
  final numbers = <int>[1, 2, 3, 5, 6, 7];
  var result = numbers.firstWhere((e) => e < 5); // 1
  print(result);
  result = numbers.firstWhere((e) => e > 5); // 6
  print(result);
  result = numbers.firstWhere((e) => e > 10, orElse: () => -1); // -1
  print(result);
  print(numbers[0]);
  // result = numbers.where((v) => v>10).first;
  print(numbers.where((v) => v>10));
  print(numbers.firstWhereOrNull((v) => v>10));


  try {
    result = numbers.firstWhere((e) => e > 10);
    print(result);
  } on StateError catch(e){
    print(e.message);
  }catch (e) {
    print(e);
    print(e.runtimeType);
  }
}

main() {
  testFirstWhere();
}
